home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / stactics.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  2KB  |  93 lines

  1.  
  2. #include "driver.h"
  3.  
  4. /* needed in vidhrdw/stactics.c */
  5. int stactics_vert_pos;
  6. int stactics_horiz_pos;
  7. unsigned char *stactics_motor_on;
  8.  
  9. /* defined in vidhrdw/stactics.c */
  10. extern int stactics_vblank_count;
  11. extern int stactics_shot_standby;
  12. extern int stactics_shot_arrive;
  13.  
  14. READ_HANDLER( stactics_port_0_r )
  15. {
  16.     if (*stactics_motor_on & 0x01)
  17.     {
  18.         return (input_port_0_r(0)&0x7f);
  19.     }
  20.     else if ((stactics_horiz_pos == 0) && (stactics_vert_pos == 0))
  21.     {
  22.         return (input_port_0_r(0)&0x7f);
  23.     }
  24.     else
  25.     {
  26.         return (input_port_0_r(0)|0x80);
  27.     }
  28. }
  29.  
  30. READ_HANDLER( stactics_port_2_r )
  31. {
  32.     return (input_port_2_r(0)&0xf0)+(stactics_vblank_count&0x08)+(rand()%8);
  33. }
  34.  
  35. READ_HANDLER( stactics_port_3_r )
  36. {
  37.     return (input_port_3_r(0)&0x7d)+(stactics_shot_standby<<1)
  38.                  +((stactics_shot_arrive^0x01)<<7);
  39. }
  40.  
  41. READ_HANDLER( stactics_vert_pos_r )
  42. {
  43.     return 0x70-stactics_vert_pos;
  44. }
  45.  
  46. READ_HANDLER( stactics_horiz_pos_r )
  47. {
  48.     return stactics_horiz_pos+0x80;
  49. }
  50.  
  51. int stactics_interrupt(void)
  52. {
  53.     /* Run the monitor motors */
  54.  
  55.     if (*stactics_motor_on & 0x01) /* under joystick control */
  56.     {
  57.         int ip3 = readinputport(3);
  58.         int ip4 = readinputport(4);
  59.  
  60.         if ((ip4 & 0x01) == 0)    /* up */
  61.             if (stactics_vert_pos > -128)
  62.                 stactics_vert_pos--;
  63.         if ((ip4 & 0x02) == 0)    /* down */
  64.             if (stactics_vert_pos < 127)
  65.                 stactics_vert_pos++;
  66.         if ((ip3 & 0x20) == 0)    /* left */
  67.             if (stactics_horiz_pos < 127)
  68.                 stactics_horiz_pos++;
  69.         if ((ip3 & 0x40) == 0)    /* right */
  70.             if (stactics_horiz_pos > -128)
  71.                 stactics_horiz_pos--;
  72.     }
  73.     else /* under self-centering control */
  74.     {
  75.         if (stactics_horiz_pos > 0)
  76.             stactics_horiz_pos--;
  77.         else if (stactics_horiz_pos < 0)
  78.             stactics_horiz_pos++;
  79.         if (stactics_vert_pos > 0)
  80.             stactics_vert_pos--;
  81.         else if (stactics_vert_pos < 0)
  82.             stactics_vert_pos++;
  83.     }
  84.  
  85.     return interrupt();
  86. }
  87.  
  88. WRITE_HANDLER( stactics_coin_lockout_w )
  89. {
  90.     coin_lockout_w(offset, ~data & 0x01);
  91. }
  92.  
  93.